import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JScrollBar;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * This class is Teacher UI
 */
public class TeacherUI extends JPanel {

	/**
	* Variables that will receive the input
	*/
	private JLabel lbltitle = null;
	private JButton btnDefineAss = null;
	private JButton btnReturnAss = null;
	private JButton btnGrades = null;
	public JButton btnHelp = null;
	private JPanel curPanel;
	public JButton btnLogout = null;
	

	/**
	* Constructs an instance of TeacherUI.
	*/	
	public TeacherUI () {
		super();
		initialize();
	}
	/**
	* Init all the Variables
	*/
	private void initialize() {
		curPanel = this;
		btnDefineAss = new JButton();
		btnDefineAss.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				SQL s = new SQL(Global.logIn.getUserlogin(),17);
				s.accept();
				System.out.println("TEMP MSG   " + Global.chat.temp);
				DefineAssignmentUI defineAssignmentUI;
				Object msg = s.getMsg();
				if (msg.equals("NoCourses")) // NoCourses
				{
					defineAssignmentUI = new DefineAssignmentUI();
				}
				else // Receive teacher courses
				{
					System.out.println("Define Assignment Return Courses " + msg.toString());	
					defineAssignmentUI = new DefineAssignmentUI(msg);
				}
					
				setVisible(false);
				System.out.println("Define Assignment");
				Global.main.setContentPane(defineAssignmentUI);
				defineAssignmentUI.btnBack.addActionListener(new ActionListener() {   //back from defineAssignmentUI
					public void actionPerformed(ActionEvent arg0) {
						Global.main.setContentPane(curPanel);
						curPanel.setVisible(true);
					}
				});
			}
		});
		btnDefineAss.setBounds(new Rectangle(130, 87, 200, 25));
		btnDefineAss.setText("Define Assignment");
		this.add(btnDefineAss,null);
		this.setVisible(true);
		
		/**
		 *  Grades button Assignment button Implementation
		 */
		btnGrades = new JButton();
		btnGrades.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				SQL s = new SQL(Global.logIn.getUserlogin(),17);
				s.accept();
				System.out.println("TEMP MSG   " + Global.chat.temp);
				RetrunGradesUI retrunGradestUI;
				Object msg = s.getMsg();
				if (msg.equals("NoCourses")) // NoCourses
				{
					retrunGradestUI = new RetrunGradesUI();
				}
				else // Receive teacher courses
				{
					System.out.println("Return Grades Return Courses " + msg.toString());	
					retrunGradestUI = new RetrunGradesUI(msg);
				}
					
				setVisible(false);
				System.out.println("Return Grdes");
				Global.main.setContentPane(retrunGradestUI);
				retrunGradestUI.btnBack.addActionListener(new ActionListener() {   //back from 
					public void actionPerformed(ActionEvent arg0) {
						Global.main.setContentPane(curPanel);
						curPanel.setVisible(true);
					}
				});
			}
		});
		btnGrades.setBounds(new Rectangle(130, 188, 200, 25));
		btnGrades.setText("Retrun Grades");
		this.add(btnGrades,null);
		this.setVisible(true);
		
		/**
		 *  Return Assignment button Implementation
		 */
		btnReturnAss = new JButton();
		btnReturnAss.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				SQL s = new SQL(Global.logIn.getUserlogin(),17);
				s.accept();
				System.out.println("TEMP MSG   " + Global.chat.temp);
				RetrunAssignmentUI retrunAssignmentUI;
				Object msg = s.getMsg();
				if (msg.equals("NoCourses")) // NoCourses
				{
					retrunAssignmentUI = new RetrunAssignmentUI();
				}
				else // Receive teacher courses
				{
					System.out.println("Return Assignment Return Courses " + msg.toString());	
					retrunAssignmentUI = new RetrunAssignmentUI(msg);
				}
					
				setVisible(false);
				System.out.println("Return Assignment");
				Global.main.setContentPane(retrunAssignmentUI);
				retrunAssignmentUI.btnBack.addActionListener(new ActionListener() {   //back from defineAssignmentUI
					public void actionPerformed(ActionEvent arg0) {
						Global.main.setContentPane(curPanel);
						curPanel.setVisible(true);
					}
				});
			}
		});
		btnReturnAss.setBounds(new Rectangle(130, 139, 200, 25));
		btnReturnAss.setText("Retrun Assignment");
		this.add(btnReturnAss,null);
		this.setVisible(true);
		
		
		lbltitle = new JLabel("Teacher Log In");
		lbltitle.setBounds(193, 28, 110, 14);

		this.setSize(400, 321);
		this.setLayout(null);
		
		this.add(lbltitle);
	
		this.setVisible(true);
		/**
		 *  help button Implementation
		 */
		btnHelp = new JButton("Help");
		btnHelp.setBounds(390, 11, 80, 19);
		btnHelp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				  HelpWin help = new HelpWin ("Choose  one of the options");
				  System.out.println("user press Help button");
			}
		});
		this.add(btnHelp,null);
		/**
		 *  Logout button Implementation
		 */
		btnLogout = new JButton("Logout");     //Logout button
		btnLogout.setBounds(10, 11, 80, 19);
		add(btnLogout);
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		   		  LogoutWin logt = new LogoutWin();
				  System.out.println("user press Logout button");
			}
		});
		
		this.setVisible(true);
		
	}
			
			
}
